package org.osiris.client.services;

import org.osiris.client.model.UsuarioViewBean;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * Authentication service.
 * 
 * @author See Wah Cheng
 * @created 5 Jun 2009
 */
public interface AuthenticationService extends RemoteService {

	public static final String SERVICE_URI = "authenticationService";

	public static class Util {

		public static AuthenticationServiceAsync getInstance() {

			AuthenticationServiceAsync instance = (AuthenticationServiceAsync) GWT.create(AuthenticationService.class);
			ServiceDefTarget target = (ServiceDefTarget) instance;
			target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
			return instance;
		}
	}

	/**
	 * Authenticates user.
	 * 
	 * @param username
	 * @param password
	 * @return whether authentication is successful
	 */
	UsuarioViewBean authenticate(String username, String password);

	/**
	 * Terminates a user's security session.
	 */
	void logout();
}
